<?php
// Template Name: Login
?>
	<?php $redirectTo = (isset($_GET["redirect_to"]) && !empty($_GET["redirect_to"]))  ? $_GET["redirect_to"]: "";?>
<!-- facebook -->
<script type="text/javascript">
			var currentUrl='<?php echo get_template_directory_uri(); ?>' + '/controller/openId-controller.php';
			currentUrl = encodeURIComponent(currentUrl);		
			var state = "<?php echo base64_encode($redirectTo); ?>";
			var aSignupFb = document.getElementById("aSignupFb");
                        var appId = "629757323723973";
                        var appSecrect = "84712023d7a767b9072ba9f7f3f2d90b";
            
            function openPopup(){
                url = "https://www.facebook.com/dialog/oauth?client_id="+appId+"&scope=publish_stream,email&redirect_uri="+currentUrl+"&display=popup&state="+state;
				var width = 600;
                var height = 300;
                var left = parseInt((screen.availWidth/2) - (width/2));
                var top = parseInt((screen.availHeight/2) - (height/2));
                var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
				newwindow= window.open(url,'Login_by_facebook', windowFeatures);
                newwindow.focus();
            }

			function openPopupOpenId(provider, nextUrl,  width, height){
				var w = width;
				var h = height;
				
				var w = 550;
				var h = 500;
				
				var url = '<?php echo get_template_directory_uri()."/controller/openId-controller.php?provider="; ?>' + provider+ "&next=" + nextUrl;
				var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
				var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
				var left = ((screen.width / 2) - (w / 2)) + dualScreenLeft;
				var top = ((screen.height / 2) - (h / 2)) + dualScreenTop;
							window.open(url, '_blank',  'width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
							
			}
            
  </script>


<div class="content">

	<div class="content_botbg">

		<div class="content_res">

			<!-- full block -->
			<div class="shadowblock_out">

				<div class="shadowblock">

					<h2 class="dotted">
						<span class="colour"><?php _e( 'Đăng nhập', APP_TD ); ?> </span>
					</h2>

					<?php do_action( 'appthemes_notices' ); ?>
                                        <div class="left-box">
                                            	<p class="text-center">
						<?php _e( 'Vui lòng điền đầy đủ thông tin để đăng nhập.', APP_TD ); ?>
                                                </p>

						<form action="<?php echo wp_login_url(); ?>" method="post"
							class="loginform" id="login-form">

							<p>
								<label for="login_username"><?php _e( 'Email:', APP_TD ); ?>
								</label> <input type="text" class="text required" name="log"
									id="login_username"
									value="<?php if (isset($posted['login_username'])) echo esc_attr($posted['login_username']); ?>" />
							</p>

							<p>
								<label for="login_password"><?php _e( 'Mật khẩu:', APP_TD ); ?>
								</label> <input type="password" class="text required" name="pwd"
									id="login_password" value="" />
							</p>

							<div class="clr"></div>

							<div id="checksave">

								<p class="rememberme">
									<input name="rememberme" class="checkbox" id="rememberme"
										value="forever" type="checkbox" checked="checked" /> <label
										for="rememberme"><?php _e( 'Nhớ tôi trong 2 tuần', APP_TD ); ?> </label>
								</p>

								<p class="submit">
									<input type="submit" class="btn_orange" name="login" id="login"
										value="<?php _e( 'Đăng nhập', APP_TD ); ?>" />
									<?php echo APP_Login::redirect_field(); ?>
									<input type="hidden" name="testcookie" value="1" />
								</p>

								<p class="lostpass">
                                                                    	<a class="lostpass"
										href="<?php echo appthemes_get_password_recovery_url(); ?>"
										title="Quên mật khẩu">Nhấn vào đây nếu bạn quên mật khẩu
									</a>
                                                                </p>

								

								<?php do_action('login_form'); ?>

							</div>

						</form>
						<!-- autofocus the field -->
						<script type="text/javascript">try{document.getElementById('login_username').focus();}catch(e){}</script>

					</div>
					<div class="right-box">
                                            <p class="text-center">
						Hoặc đăng nhập bằng:
                                                </p>
						<div class="social-login" id="login-by-facebook-id" onclick="openPopup();"></div>
						<div class="social-login" id="login-by-google-id" onclick="openPopupOpenId('GOOGLE' ,'<?php echo $redirectTo; ?>');"></div>
						<div class="social-login" id="login-by-yahoo-id" onclick="openPopupOpenId('YAHOO', '<?php echo $redirectTo; ?>');"></div>
					</div>
					<div class="clr"></div>

				</div>
				<!-- /shadowblock -->

			</div>
			<!-- /shadowblock_out -->

		</div>
		<!-- /content_res -->

	</div>
	<!-- /content_botbg -->

</div>
<!-- /content -->
